import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import VueSetup from 'vite-plugin-vue-setup-extend'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'



// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    VueSetup(),

      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      
      Components({
        resolvers: [ElementPlusResolver()],
      }),

    ], 
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },

  //代理服务器
  server: {
    // 配置代理
    proxy: {
      '/api': {
        target: 'https://149f66bf6e8048149bc3ed40851e699c.apig.cn-north-4.huaweicloudapis.com/',
        changeOrigin: true, // 允许跨域
        rewrite: (path) => path.replace(/^\/api/, ''), // 重写路径
      },
    },
  },
});
